﻿using System;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    internal class FtNts
    {
        private bool _fSharedNote;
        private Guid _guid = Guid.NewGuid();
        private uint _unused = 524479;

        public void Read(BinaryReader reader)
        {
            ushort ft = reader.ReadUInt16();
            Contract.Assert(ft == 0x000D);
            ushort cb = reader.ReadUInt16();
            Contract.Assert(cb == 0x0016);
            _guid = new Guid(reader.ReadBytes(16));
            _fSharedNote = reader.ReadUInt16() != 0;
            _unused = reader.ReadUInt32();
        }

        public void Write(BinaryWriter writer)
        {
            ushort ft = 0x000D;
            writer.Write(ft);
            ushort cb = 0x0016;
            writer.Write(cb);
            writer.Write(_guid.ToByteArray());
            writer.Write(_fSharedNote ? (ushort) 1 : (ushort) 0);
            writer.Write(_unused);
        }
    }
}